package com.chenye.jpa.entity;

import lombok.Data;
import lombok.ToString;
import org.hibernate.annotations.Where;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.List;

/**
 * @Auther:chenye
 * @Data:2018/5/15
 * @Description:
 */
@Entity
@Table(name = "role")
@Data
@ToString
public class Role {
    @Id
    private Integer id;
    @Column(name = "role_name")
    private String roleName;
    @Column
    private String desc;

    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.LAZY)
    @JoinColumn(name="role_id")
    @Where(clause = "group_name is not null")
    @org.hibernate.annotations.OrderBy(clause = "group_name desc")
    private List<RoleGroup> roleGroups = new ArrayList<>();
}
